<?php
// 获得轮播图信息
// header("content-type:text/html;charset=UTF-8");
include_once("conn.php");
$select = "SELECT * FROM carousel_pic_infos ORDER BY pic_AddDate ASC";

$result = mysqli_query($connect_DB, $select);
if ($result) {
    $num = mysqli_num_rows($result);
    echo "
    <div class='carousel-indicators'>
    ";
    $count = 0;
    $slide = 1;
    for ($i = 0; $i < $num; $i++) {
        if ($count == 0) {
            echo "<button type='button' data-bs-target='#carouselExampleCaptions' data-bs-slide-to='" . $count . "' class='active' aria-current='true' aria-label='Slide " . $slide . "'></button>";
        } else {
            echo "<button type='button' data-bs-target='#carouselExampleCaptions' data-bs-slide-to='" . $count . "' aria-label='Slide " . $slide . "'></button>";
        }
        $count++;
        $slide++;
    }
    echo "</div> <div class='carousel-inner'>";
    $count = 0;
    while ($row = mysqli_fetch_object($result)) {
        if ($count == 0) {
            $active = "active";
        }else{
            $active = "";
        }
        echo "
        <div class='carousel-item ".$active."'>
            <img src='../public/pic/carousel/" . $row->pic_Name . "' class='d-block w-100'>
            <div class='carousel-caption d-none d-md-block'>
                <h5>" . $row->pic_Title . "</h5>
                <p>" . $row->pic_Content . "</p>
            </div>
        </div>
        ";
        $count++;
    }
    echo"</div>";
}
?>